package com.smart.workflow.engine;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.espertech.esper.client.Configuration;
import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EPServiceProviderManager;
import com.smart.workflow.markers.RuntimeEngine;

/**
 * Standard implementation of RuntimeEngine
 * @author Lukasz
 * 
 */

@Component("runtimeEngine")
public class RuntimeEngineImpl implements RuntimeEngine {

	@Resource(name="esperConfiguration")
	private Configuration configuration;
	@Resource(name="eventEngine")
	private EventEngine eventEngine;
	
	@Override
	public void scanForEvents() {
		// TODO analyze classpath and find event triggers
		// for every event add a subscriber - statemachine class

	}

	@Override
	public void sendEvent(Object event) {
		EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
		epService.getEPRuntime().sendEvent(event);
	}

}
